<template>
	<view class="pop-refund-choose-guige">
		<u-popup :show="show_pop" bgColor="#FFFFFF" :round="24" :closeable="true" mode="bottom" @close="onclose"
			@open="onopen">
			<scroll-view scroll-y="true" class="refund-scroll">
				<view class="refund-box">
					<view class="refund-title">换新商品</view>
					<view class="tips">
						价格相同的商品才可以换货哦
					</view>
					<view class="goods-shuxing">
						<view class="shuxing-item-box">
							<view class="shuxing-item">
								<view class="item-con flex-center" v-for="(item,index) in exchange_products" :key="index"
									:class="(exchange_select.id==item.id)?'item-active':(item.is_change_ok==0)?'hui':''"
									@click="toggleExchange(item,index)">
									<text>{{item.keyVals || ''}}</text>
								</view>
							</view>
						</view>
					</view>
					<view class="goods-num">
						<text>数量</text>
						<view class="">
							<u-number-box :max="buyNumber" :min="1" v-model="buyNumber" @change="valChange"></u-number-box>
						</view>
					</view>
				</view>

				<view class="page-foot">
					<view class="safe-fixed-bottom">
						<view class="btn flex-center btn-cancel" @click="doConfirm()">
							完成
						</view>
					</view>
				</view>

				<!-- <view class="bottom safe-area-inset-bottom" @click="Confirm">
					<view class="btn">完成</view>
				</view> -->
			</scroll-view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				show_pop: false,
				exchange_products: [],
				exchange_select: {},
				buyNumber: 1,
				oldProduct: {}
			}
		},
		computed: {

		},
		watch: {

		},
		methods: {
			init(exchange_products, product) {
				this.exchange_products = exchange_products;
				this.buyNumber = product.num
				this.oldProduct = product
				this.show_pop = true;
			},
			onclose() {
				this.show_pop = false;
			},
			onopen() {},
			toggleExchange(item) {
				if (item.isChangeOk == 0) {
					this.$alert('不支持更换此商品')
					return
				}
				this.exchange_select = item;
			},

			valChange() {

			},

			doConfirm() {
				if (!this.exchange_select.id) {
					this.$alert('请选择换货商品')
					return
				}
				this.$emit('confirm', this.exchange_select, this.buyNumber)
				this.show_pop = false;
			}
		},
	}
</script>

<style lang="scss" scoped>
	.pop-refund-choose-reason {
		position: relative;
		z-index: 1000;
	}


	.info-modal-wrap {
		width: 574rpx;
		width: 660rpx;
		width: 100%;
		position: relative;
		text-align: left;
		padding-bottom: 0;
		// padding-bottom: calc(64rpx + constant(safe-area-inset-bottom));
		// padding-bottom: calc(64rpx + env(safe-area-inset-bottom));

		.info-modal-inner {
			border-radius: 16rpx;
			overflow: hidden;
			width: 100%;
			padding: 0 0;
			padding-bottom: 0;
			min-height: 400rpx;
			background: #FFFFFF;
			background: #F6FAFD;
		}
	}




	.refund-scroll {
		width: 100%;
		background: #FFFFF;

		.refund-box {
			border-radius: 24rpx 24rpx 0rpx 0rpx;
			padding: 22rpx 32rpx 220rpx;

			.refund-title {
				text-align: center;
				font-size: 32rpx;
				/* font-weight: bold; */
				color: #000000;
				margin-bottom: 42rpx;
			}

			.tips {
				font-size: 24rpx;
				color: #000000;
			}

			.refund-select {
				background: #FFFFFF;
				border-radius: 8rpx;
				margin-top: 38rpx;
				padding: 32rpx 24rpx 40rpx;

				.refund-select-title {
					font-size: 32rpx;
					font-weight: bold;
					color: #000000;
					margin-bottom: 26rpx;
				}

				.select-type {
					display: flex;
					align-items: center;

					.type-item {
						width: 202rpx;
						height: 72rpx;
						line-height: 72rpx;
						text-align: center;
						border-radius: $radius;
						border: 2rpx solid #E1E3E8;
						font-size: 28rpx;
						margin-right: 16rpx;
						background: #FFFFFF;
						border: 2rpx solid #E1E3E8;

						&:nth-last-of-type(1) {
							margin-right: 0;
						}
					}

					.type-item-active {
						background: $color;
						font-size: 28rpx;
						color: #FFFFFF;
					}
				}
			}

			.order-goods-info {
				background: #FFFFFF;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				margin-top: 16rpx;
				padding: 34rpx 24rpx 40rpx;

				.goods-info-title {
					font-size: 28rpx;
					font-weight: bold;
					color: #222222;
				}

				.goods-info-box {
					margin-top: 26rpx;
					display: flex;

					.goods-info-left {
						width: 176rpx;
						border-radius: 8rpx 8rpx 8rpx 8rpx;
						margin-right: 32rpx;

						image {
							width: 100%;
						}
					}

					.goods-info-right {
						flex: 1;
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.goods-title {
							word-break: break-all;
							display: -webkit-box;
							-webkit-line-clamp: 2;
							-webkit-box-orient: vertical;
							overflow: hidden;
							font-size: 28rpx;
							font-weight: bold;
							color: #000000;
						}

						.goods-subtitle {
							font-size: 24rpx;
							color: #999999;
							flex: 1;
							margin-top: 8rpx;
						}

						.goods-price-box {
							display: flex;
							align-items: center;
							justify-content: space-between;

							text {
								&:nth-child(1) {
									font-size: 28rpx;
									font-weight: bold;
									color: #000000;
								}

								&:nth-last-of-type(1) {
									font-size: 24rpx;
									font-weight: bold;
									color: #000000;
								}
							}
						}
					}
				}
			}

			.refund-reason {
				background: #FFFFFF;
				border-radius: 8rpx;
				padding: 34rpx 24rpx;
				margin-top: 38rpx;

				.reason-item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-bottom: 68rpx;
					font-size: 28rpx;

					>label {
						width: 100%;
						display: flex;
						align-items: center;
						justify-content: space-between;

						text {
							font-size: 28rpx;
						}
					}

					&:nth-last-of-type(1) {
						margin-bottom: 0;
					}

					/deep/.uni-label-pointer {
						display: flex;
						align-items: center;
						justify-content: space-between;
						width: 100%;

						text {
							font-size: 28rpx;
							color: #000000;
						}

						/deep/uni-radio .uni-radio-input {
							width: 32rpx;
							height: 32rpx;
							background: #63E188;
						}
					}
				}
			}

			.refund-scroll {
				width: 100%;
				background: #F5F7F9;
			}

			.refund-remark {
				background: #FFFFFF;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				padding: 28rpx 24rpx 26rpx;
				margin-top: 38rpx;
				font-size: 24rpx;
				font-weight: bold;
				color: #F74E3B;
			}

			.refund-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 42rpx;
				margin-bottom: 52rpx;

				&:nth-last-of-type(1) {
					margin-bottom: 0;
				}

				text {
					font-size: 28rpx;
					color: #000000;

					&:nth-child(1) {
						margin-right: 90rpx;
						white-space: nowrap;
					}

					&:nth-child(2) {
						font-size: 28rpx;
						color: #9695A3;
						white-space: nowrap;
					}
				}

				.refund-item-right {
					display: flex;
					align-items: center;

					text {
						font-size: 28rpx;
						color: #000000;
						margin-right: 30rpx;
					}

					input {
						text-align: right;
					}

					.edit_icon {
						width: 28rpx;
						height: 28rpx;
					}
				}

				.zhiliang {
					text {
						font-size: 28rpx;
						color: #9695A3;
					}
				}

				.price {
					text {
						font-size: 28rpx;
					}
				}
			}

			.status-box {
				background: #FFFFFF;
				border-radius: 8rpx;
				padding: 34rpx 24rpx;
				margin-top: 38rpx;

				/deep/.u-radio-group--row {
					flex-direction: column !important;
				}

				.status-item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-bottom: 68rpx;

					&:nth-last-of-type(1) {
						margin-bottom: 0;
					}

					text {
						font-size: 28rpx;
						color: #000000;
					}
				}
			}

			.shouhou-type {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 52rpx;

				text {
					font-size: 28rpx;
				}
			}

			.goods-shuxing {
				margin-top: 38rpx;

				.shuxing-item-box {
					border-bottom: 2rpx solid #F3F4F8;
					padding-bottom: 18rpx;

					.shuxing-item-title {
						font-size: 28rpx;
						font-weight: bold;
						color: #000000;
						margin-bottom: 24rpx;
						margin-top: 30rpx;
					}

					.shuxing-item {
						display: flex;
						align-items: center;
						flex-wrap: wrap;

						.item-con {
							width: 334rpx;
							height: 64rpx;
							line-height: 64rpx;
							border-radius: 50rpx 50rpx 50rpx 50rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 28rpx;
							color: #000000;
							margin-bottom: 16rpx;


							&:nth-child(2n) {
								margin-right: 0;
							}
						}

						.item-active {
							color: #FFFFFF;
							background: #CB0011;
						}

						.hui {
							background: #E9E5E5;
							border-radius: 8rpx 8rpx 8rpx 8rpx;
							font-size: 28rpx;
							color: #AF9C9C;
							border-radius: 50rpx 50rpx 50rpx 50rpx;
						}
					}

				}
			}

			.goods-num {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 30rpx;
				/* /deep/.u-number-box__plus, .u-number-box__minus{
							width: 60rpx;
							height: 60rpx !important;
							background: #F3F4F8;
							border-radius: 4rpx 0rpx 0rpx 4rpx;
						} */
			}
		}
	}



	.goods-shuxing {
		margin-top: 38rpx;

		.shuxing-item-box {
			border-bottom: 2rpx solid #F3F4F8;
			padding-bottom: 18rpx;

			.shuxing-item-title {
				font-size: 28rpx;
				font-weight: bold;
				color: #000000;
				margin-bottom: 24rpx;
				margin-top: 30rpx;
			}

			.shuxing-item {
				display: flex;
				align-items: center;
				flex-wrap: wrap;

				.item-con {
					margin-right: 16rpx;
					width: 50%;
					height: 64rpx;
					background: #F6FAFD;
					border-radius: 50rpx 50rpx 50rpx 50rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #000000;


					&:nth-child(2) {
						margin-right: 0;
					}
				}

				.item-active {
					font-size: 28rpx;
					color: #FFFFFF;
					background: #000000;
				}

				.hui {
					background: #E9E5E5;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					font-size: 28rpx;
					color: #AF9C9C;
					border-radius: 50rpx 50rpx 50rpx 50rpx;
				}
			}

		}
	}


	.page-foot {
		.btn {
			flex: 1;
			// width: 345rpx;
			height: 80rpx;
			background: #CB0011;
			border-radius: 40rpx 40rpx 40rpx 40rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #FFFFFF;
		}
	}
</style>